/*
2021-11-9
https://www.acwing.com/problem/content/4074/
*/ 

#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;
int x0,y0;
int x1,y1;
char op;
int num;
int dx[]={-2,-1,1,2,2,1,-1,-2};
int dy[]={1,2,2,1,-1,-2,-2,-1};

bool check(int x,int y)
{
    for(int i=0;i<8;i++)
    {
        int a=x+dx[i],b=y+dy[i];
        if((a==x0 && b==y0) || (a==x1 && b==y1))
            return false;
    }
    return true;
}

int main()
{
    cin>>op>>num;
    x0=op-'a'+1;
    y0=num;
    
    cin>>op>>num;
    x1=op-'a'+1;
    y1=num;
    
    int ans=0;
    for(int i=1;i<=8;i++)
        for(int j=1;j<=8;j++)
            if(i!=x0 && j!=y0)
            {
                if(i==x1 && j==y1) continue;
                else if(check(i,j)) ans++;
            }
        
    cout<<ans<<endl;
    
    return 0;
}
